﻿<views:MvxWpfView 
	x:Class="Sidvall.FileSystemManager.UI.Wpf.Views.SearchConfigView"
	xmlns:views="clr-namespace:MvvmCross.Wpf.Views;assembly=MvvmCross.Wpf"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters;assembly=Sidvall.UI.Wpf"
	xmlns:vms="clr-namespace:Sidvall.FileSystemManager.UI.ViewModels;assembly=Sidvall.FileSystemManager.UI"
	xmlns:Controls="clr-namespace:Sidvall.FileSystemManager.UI.Wpf.Controls"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	mc:Ignorable="d" 
	d:DesignHeight="400" d:DesignWidth="600">

	<views:MvxWpfView.Resources>
		<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
	</views:MvxWpfView.Resources>

	<Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:SearchConfigViewModel}}" IsEnabled="{Binding IsBusy, Converter={StaticResource InverseBooleanConverter}}">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<Controls:HeaderControl HeaderCaption="Search" HeaderHorizontalContentAlignment="Center" FontSize="14" FontWeight="Bold"/>

		<Grid Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>

			<Grid Grid.Column="0">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>

				<Label Content="Root Folder:"/>
				<TextBox Grid.Column="1" Grid.ColumnSpan="5" Text="{Binding ActiveEntity.FolderPath}" />

				<Label Grid.Row="1" Content="Search For:"/>
				<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" Text="{Binding ActiveEntity.SearchPatterns}" />

				<Label Grid.Row="2" Content="File Include Patterns:"/>
				<ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="5" IsEditable="True" ItemsSource="{Binding SearchPatterns}" DisplayMemberPath="Name" SelectedValuePath="Name" Text="{Binding ActiveEntity.FileSearchPatterns}" ToolTip="Separator = pipeline (|)" />

                <CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding ActiveEntity.CaseSensitive}" VerticalAlignment="Center" HorizontalAlignment="Left"
                          Margin="0,5,0,0">Case Sensitive</CheckBox>
                <CheckBox Grid.Row="5" Grid.Column="1" IsChecked="{Binding ActiveEntity.SearchFileName}" VerticalAlignment="Center" HorizontalAlignment="Left"
                          Margin="0,5,0,0">Search File Name</CheckBox>
                <CheckBox Grid.Row="5" Grid.Column="3" IsChecked="{Binding ActiveEntity.SearchFileContent}" VerticalAlignment="Center" HorizontalAlignment="Left"
                          Margin="5,5,0,0">Search File Content</CheckBox>
                <CheckBox Grid.Row="5" Grid.Column="5" IsChecked="{Binding ActiveEntity.SearchFolderName}" VerticalAlignment="Center" HorizontalAlignment="Left"
                          Margin="5,5,0,0">Search Folder Name</CheckBox>
                <CheckBox Grid.Row="6" Grid.Column="1" IsChecked="{Binding ActiveEntity.LoadDetails}" VerticalAlignment="Center" HorizontalAlignment="Left"
                          Margin="0,5,0,0">Load Details</CheckBox>
			</Grid>
		</Grid>
        <Grid Grid.Row="2" Margin="0,5,0,0">
			<TextBox Text="{Binding Result}" IsReadOnly="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" Height="50" />
		</Grid>
		<Grid Grid.Row="3">
			<DataGrid Margin="0,5,0,0" RowHeaderWidth="0" ItemsSource="{Binding Files}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" SelectedItem="{Binding ActiveFile}">
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="MouseDoubleClick">
						<i:InvokeCommandAction Command="{Binding ShowFileCommand}" />
					</i:EventTrigger>
				</i:Interaction.Triggers>
				<DataGrid.Columns>
					<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" Width="Auto" />
					<DataGridTextColumn Header="Folder" Binding="{Binding Folder}" IsReadOnly="True" Width="*" />
					<DataGridTextColumn Header="Size" Binding="{Binding Size}" IsReadOnly="True" Width="Auto" MinWidth="30" />
				</DataGrid.Columns>
			</DataGrid>
		</Grid>
		<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="0,5,0,0">
			<Button Width="100" Height="36" Command="{Binding SearchCommand}" Content="Search"/>
		</StackPanel>
	</Grid>
</views:MvxWpfView>
